package com.syedu.day08.v2;

//静态导入
import static com.syedu.day08.v2.VehicleFactory.*;

/**
 * @Description
 * @createTime 2022/3/18 9:34
 * @author Administrator
 */
public class TestVehicle {
    public static void main(String[] args) {
        //创建业务类对象
        VehicleService service = new VehicleService();

        //创建交通工具对象
        //Car car = new Car("奇瑞","QQ");
        //MotoBike motoBike = new MotoBike("宝马","s1000R");
        //Boat boat = new Boat("","");

        //Vehicle vehicle = VehicleFactory.getVehicle(2);

        /**
         * 使用工厂来创建对象,没有出现具体的子类对象,都是面向父类的,
         * 可以隐藏子类,提高代码的维护性和后期的拓展性
         */
        //使用常量提高代码的可读性
        //Vehicle vehicle = VehicleFactory.getVehicle(VehicleFactory.CAR);

        //使用静态导入简化调用
        Vehicle vehicle = getVehicle(CAR);
        vehicle.setBrand("奇瑞");
        vehicle.setType("QQ");

        //调用业务方法
        service.goWork(vehicle);
    }
}
